<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <?php include "../controller/task_detail.php" ;?>
    <?php include 'modules/head.php'; ?>
    <style>

        .mui-content, html{ background: #fff}
        .title{padding: 25px 0;
            text-align: center;
            font-size: 21px;}
        .info{line-height: 28px; padding: 10px 0 0 0;
            font-size: 16px;}

        #no-data{
            display: flex;
            justify-content: center;
            margin-top: 10px;
            font-size: 15px;
        }
        #log-list{
            max-height: 370px;
            overflow-y: auto;
        }
        .comment-list .notice_list{
            margin-top: 2px;
        }
        .comment-list .item{
            width: 100%;
            display: flex;
            position: relative;
            margin-bottom: 20px;
        }
        .comment-list .item:last-child{
            margin-bottom: unset;
        }
        .comment-list .item .left{
            width: 50px;
        }
        .comment-list .item .left .img-box{
            text-align: center;
        }
        .comment-list .item .left .img-box img{
            width: 30px;
            height: 30px;
            margin-right: 10px;
            border-radius: 50%;
        }
        .comment-list .item .right{
            width: calc(100% - 70px);
            display: flex;
            flex-direction: column;
        }
         .comment-list .item .right .head{
            display: flex;
            justify-content: space-between;
            margin-top: 2px;
        }
         .comment-list .item .right .head .date{
            color: #909aaa;
        }
        .comment-list .item .right .content{
            max-width: 100%;
            word-wrap: break-word;
            overflow: hidden;
            margin-top: 10px;
        }
         .comment-list .item .right .content .img-group .file-item{
            width: 70px;
            height: 70px;
            object-fit: cover;
            padding: 10px;
            background-color: #F7F7F7;
            margin-top: 10px;
            margin-right: 10px;
            border-radius: 5px;
            position: relative;
        }
         .comment-list .item .right .content .img-group .file-item:last-child{
            margin-right: unset;
        }
        .ke-edit {
            height: 120px !important;
        }
        .notice_member span{
            padding-bottom: 5px;
        }
        .reply{
            position: relative;
            margin-top: 30px;
        }
        .reply h6 {
            font-size: 18px;
            padding-bottom: 8px;
            font-weight: bold;
            color: rgba(0, 0, 0, 0.85);
        }
        .reply textarea{
            height: 100px;
        }
        .reply button{
            position: absolute;
            bottom: 5px;
            right: 5px;
        }
    </style>
</head>

<body id="top">

<?php include 'modules/header.php'; ?>




<div class="mui-content">


    <div class="layui-container">

        <div class="layui-row title">
            <? echo $task['title']?>
        </div>

        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li>项目详情</li>
                <li class="layui-this">通知信息</li>

            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item  layui-show">
                    <div class="layui-row info">
                        <div class="layui-col-xs3  layui-col-md4">
                            执行人：
                        </div>
                        <div class="layui-col-xs9  layui-col-md8">
                            <?
                                if($principal_list){


                                for($i=0;$i<count($principal_list);$i++){ ?>
                                <?php if($task['principal'] == $principal_list[$i]['nid']){echo $principal_list[$i]['name'];} ?>
                            <? }
                                }
                                else{
                                    echo '无';
                                }
                                ?>
                        </div>

                    </div>
                    <div class="layui-row info">
                        <div class="layui-col-xs3  layui-col-md4">
                            项目：
                        </div>
                        <div class="layui-col-xs9  layui-col-md8">
                            <?
                            if($case_list){


                                for($i=0;$i<count($case_list);$i++){ ?>
                                    <?php if($task['case_id'] == $case_list[$i]['nid']){echo $case_list[$i]['name'];} ?>
                                <? }
                            }
                            else{
                                echo '无';
                            }
                            ?>
                        </div>
                    </div>
                    <div class="layui-row info">
                        <div class="layui-col-xs3  layui-col-md4">
                            开始时间：
                        </div>
                        <div class="layui-col-xs9  layui-col-md8">
                            <? echo $task['startdate']?>
                        </div>
                    </div>
                    <div class="layui-row info">
                        <div class="layui-col-xs3  layui-col-md4">
                            截止时间：
                        </div>
                        <div class="layui-col-xs9  layui-col-md8">
                            <? echo $task['enddate']?>
                        </div>
                    </div>
                    <div class="layui-row info">
                        <div class="layui-col-xs3  layui-col-md4">
                            完成时间：
                        </div>
                        <div class="layui-col-xs9  layui-col-md8">
                            <?php if($task['completedate']){echo $task['completedate'];}else{echo $task['enddate'];} ?>
                        </div>
                    </div>
                    <div class="layui-row info">
                        <div class="layui-col-xs3  layui-col-md4">
                            备注：
                        </div>
                        <div class="layui-col-xs9  layui-col-md8">
                            <?php echo $task['note'] ?>
                        </div>
                    </div>
                    <div class="layui-row info">
                        <div class="layui-col-xs3  layui-col-md4">
                            优先级：
                        </div>
                        <div class="layui-col-xs9  layui-col-md8">
                            <? if($task['priority']=="无"){echo "无";} ?>
                            <? if($task['priority']=="普通"){echo "普通";} ?>
                            <? if($task['priority']=="紧急"){echo "紧急";} ?>
                        </div>
                    </div>
                    <div class="layui-row info">
                        <div class="layui-col-xs3  layui-col-md4">
                            状态：
                        </div>
                        <div class="layui-col-xs9  layui-col-md8">

                                <? if($task['status']=="未开始"){echo "未开始";} ?>

                                <? if($task['status']=="进行中"){echo "进行中";} ?>

                                <? if($task['status']=='待审核'){echo "待审核";} ?>

                            <?php if ($auth): ?>
                                    <? if($task['status']=="已完成"){echo "已完成";} ?>

                            <?php endif; ?>
                        </div>
                    </div>
                    <div class="layui-row info">
                        <div class="layui-col-xs3  layui-col-md4">
                            任务重复：
                        </div>
                        <div class="layui-col-xs9  layui-col-md8">

                            <? if(($task['circulate']=="不重复")or($task['circulate']=="")){echo "不重复";} ?>
                            <? if($task['circulate']=="每天重复"){echo "每天重复";} ?>
                            <? if($task['circulate']=="每周重复"){echo "每周重复";} ?>
                            <? if($task['circulate']=="每月重复"){echo "每月重复";} ?>
                            <? if($task['circulate']=="每年重复"){echo "每年重复";} ?>

                        </div>
                    </div>
                    <div class="layui-row info">
                        <div class="layui-col-xs3  layui-col-md4">
                            凭证：
                        </div>
                        <div class="layui-col-xs9  layui-col-md8">
                            <?php echo $task['voucher'] ?>
                        </div>
                    </div>
                </div>





                <div class="layui-tab-item layui-show">
                    <div class="detail-box comment-container">
                        <div class="comment-list" id="log-list">
                            <?php if(!count($task_comment)){echo "<span id='no-data'>暂无消息</span>";}?>
                            <?php for($i=0;$i<count($task_comment);$i++){ ?>
                                <?php $employee=select_one_line_all_items($table_Prefix."employee","nid = '".$task_comment[$i]['user_id']."'");?>
                                <div class="item">
                                    <div class="left">
                                        <div class="img-box">
                                            <?php if($employee['photo']){?>
                                                <img src="../../../uploadfiles/<?php echo $employee['photo']; ?>">
                                            <?php }else{ ?>
                                                <img src="../../../uploadfiles/default.png">
                                            <?php } ?>
                                        </div>
                                    </div>
                                    <div class="right">
                                        <div class="layui-col-md12 head">
                                            <p class="name"><span class="layui-badge layui-bg-green"><?php echo $employee['name'] ?></span></p>
                                            <p class="date"><?php echo $task_comment[$i]['date']?></p>
                                        </div>



                                        <?if($task_comment[$i]['notice_member']){?>
                                            <p class="notice_list">
                                                <span class="layui-badge layui-bg-green">通知</span>
                                                <?
                                                $_notice_member=explode(",",$task_comment[$i]['notice_member']);
                                                $_notice_member_read=explode(",",$task_comment[$i]['notice_member_read']);

                                                foreach ($_notice_member as $k=>$v){?>
                                                    <span class="layui-badge  <?if(in_array($v,$_notice_member_read)){echo "layui-bg-green";}?> "><?echo $member_name_list[$v]?></span>
                                                    <?;}?>
                                            </p>
                                            <?;}?>


                                        <div class="layui-col-md12 content">
                                            <!-- 移除图片换行产生的换行符 -->
                                            <?php $content = preg_replace('/<br>|<br \/>/i', '', $task_comment[$i]['content']); ?>
                                            <?php echo $content ?>
                                            <div class="img-group"></div>
                                        </div>
                                    </div>
                                </div>
                            <?php } ?>
                        </div>
                    </div>
                    
                    <div class="reply layui-form">
                        <h6>通知他们</h6>
                        <div class="notice_member">
                            <?
                            foreach ($principal_list as $k => $v) {

                                if (($v['status'] == "在职") and ($v['nid'] != $_SESSION['nidx'])) {
                                    ?>
                                    <span><input type="checkbox" name="ai_notice_member"
                                                value="<? echo $v['nid'] ?>"
                                                title="<? echo $v['name'] ?>"
                                                lay-skin="primary" <? if ($task['principal'] == $v['nid']) {
                                            echo "checked";
                                        } ?>>
                                    </span>
                                <? };
                            } ?>

                        </div>


                        <textarea id="ai_content" name="ai_content" cols="60"></textarea>
                        <button type="button" class="layui-btn layui-btn-sm" id="reply" onclick="reply()">回复</button>
                    </div>
                </div>
                <?php 
                    $user_id = select_one_line_all_items($table_Prefix."employee","openid='".$_REQUEST['openid']."'")['nid'];
                ?>
                <input type="hidden" name="nid" value="<? echo $_REQUEST['nid'] ?>">
                <input type="hidden" name="user_id" value="<? echo $user_id ?>">
            </div>
        </div>
    </div>
</div>
<script src="../../../controller/common/asset/js/jquery-1.10.2.min.js"></script>
<script src="../../../controller/extender/task/asset/js/create_task_log.js"></script>
<script>
    //注意：选项卡 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function(){
        var element = layui.element;

        //…
    });
</script>
<!--kindeditor编辑器-->
<script charset="utf-8" src="/application/nkeditor/NKeditor-all.js"></script>
<!-- 如果你不需要使用批量图片上传，涂鸦功能和文件管理功能，就不需要引入 jquery -->
<!--    <script charset="utf-8" src="/application/nkeditor/libs/jquery.min.js"></script>-->
<!-- JDialog是一款优秀的漂亮，轻量级的js弹出框插件 不是必须引入的，如果不引入则使用默认的 window.alert() 来弹出提示信息 -->
<script charset="utf-8" src="/application/nkeditor/libs/JDialog/JDialog.min.js"></script>
<script>
    var editor;
    KindEditor.ready(function(K) {
        editor=K.create('textarea[name="ai_content"]', {
            uploadJson : K.basePath+'php/default/upload_json.php',
            fileManagerJson : K.basePath+'php/default/file_manager_json.php',
            allowFileManager : true,
            allowImageUpload : true,
            allowMediaUpload : true,
            height:100,
            items : [],
            themeType : "black", //主题
            //错误处理 handler
            errorMsgHandler : function(message, type) {
                try {
                    JDialog.msg({type:type, content:message, timer:2000});
                } catch (Error) {
                    alert(message);
                }
            }
        });   
    });
</script>
</body>
</html>
